import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { defHttp } from '/@/utils/http/axios';
//列表数据
export const columns : BasicColumn[] = [
	{
		title: '状态 ',
		align: "center",
		dataIndex: 'stats_dictText'
	},
	/* 	{
			title: '工作人员等级',
			align: "center",
			dataIndex: 'levnum_dictText'
		}, */
	{
		title: '真实姓名',
		align: "center",
		dataIndex: 'realname'
	},
	{
		title: '代号',
		align: "center",
		dataIndex: 'codename'
	},
	{
		title: '身份证',
		align: "center",
		dataIndex: 'idCard'
	},
	{
		title: '所属城市',
		align: "center",
		dataIndex: 'cityid_dictText'
	},
	{
		title: '电话号码',
		align: "center",
		dataIndex: 'phone'
	},
	/* 	{
			title: '学校id',
			align: "center",
			dataIndex: 'schoolid'
		}, */
	{
		title: '部门',
		align: "center",
		dataIndex: 'departid_dictText'
	},
	{
		title: '头像',
		align: "center",
		dataIndex: 'cover',
		customRender: render.renderImage,
	},

	/* 	{
			title: '职位id',
			align: "center",
			dataIndex: 'jobid_dictText'
		}, */
	{
		title: '平均响应时间',
		align: "center",
		sorter: true,
		dataIndex: 'reptime'
	},
	{
		title: '接待客户总数',
		align: "center",
		sorter: true,
		dataIndex: 'clientnum'
	},
	{
		title: '成交客户总数',
		align: "center",
		sorter: true,
		dataIndex: 'makenum'
	},
	{
		title: '成交总金额',
		align: "center",
		sorter: true,
		dataIndex: 'maketotalmoney'
	},
	{
		title: '退款总额',
		align: "center",
		sorter: true,
		dataIndex: 'totalrefund'
	},
	{
		title: '备注',
		align: "center",
		dataIndex: 'extInfors',
		customRender: ({ text, record }) => {
			if (!text || text == {}) {
				return ''
			}
			if (text.indexOf("remark") > -1) {
				let remark = JSON.parse(text).remark
				if (!remark) {
					remark = JSON.parse((JSON.parse(text))).remark
				}
				return remark;
			} else {
				return ""
			}

		}
	},
	{
		title: '所属租户',
		align: "center",
		dataIndex: 'tenantId_dictText'
	},

];
//查询数据
export const searchFormSchema : FormSchema[] = [
	{
		label: "状态 ",
		field: 'stats',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "woker_stats"
		},
		//colProps: {span: 6},
	},
	/* 	{
		  label: "工作人员等级",
		  field: 'levnum',
		  component: 'JDictSelectTag',
		  componentProps:{
			  dictCode:"woder_levnum"
		  },
		  //colProps: {span: 6},
		  }, */
	/* 	{
			label: "学校id",
			field: 'schoolid',
			component: 'JDictSelectTag',
			componentProps: {
				dictCode: "couple_school,title,id"
			},
			//colProps: {span: 6},
		}, */
	{
		label: "部门id",
		field: 'departid',
		component: 'JSelectDept',
		//colProps: {span: 6},
	},
	{
		label: "所属租户",
		field: 'tenantid',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "sys_tenant,name,id"
		},
		//colProps: {span: 6},
	},
	{
		label: "所属城市",
		field: 'cityid',
		component: 'Input',
		//colProps: {span: 6},
	},
];
//表单数据
export const formSchema : FormSchema[] = [
	{
		label: '状态 ',
		field: 'stats',
		component: 'JDictSelectTag',
		componentProps: {
			dictCode: "woker_stats"
		},
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入状态 !' },
			];
		},
	},

	{
		label: '真实姓名',
		field: 'realname',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入真实姓名!' },
			];
		},
	},
	{
		label: '代号',
		field: 'codename',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入代号!' },
			];
		},
	},
	{
		label: '电话号码',
		field: 'phone',
		component: 'Input',
		dynamicRules: ({ model, schema }) => {
			return [
				{ required: true, message: '请输入电话号码!' },
			];
		},
	},

	/* 	{
			label: '学校',
			field: 'schoolid',
			component: 'JDictSelectTag',
			componentProps: {
				dictCode: "couple_school,title,id"
			},
		}, */
	{
		label: '部门',
		field: 'departid',
		component: 'JSelectDept',
	},
	/* 	{
			label: '职位id',
			field: 'jobid',
			component: 'JSearchSelect',
			componentProps: {
				dict: ""
			},
		}, */
	/* 	{
			label: '所属租户',
			field: 'tenantid',
			component: 'Input',
		}, */
	{
		field: 'cityid',
		label: '选择城市',
		component: 'ApiSelect',
		componentProps: ({ formActionType, formModel }) => {
			return {
				//multiple: 多选；不填写为单选
				mode: 'multiple',
				//请求api,返回结果{ result: { records: [{'id':'1',name:'scott'},{'id':'2',name:'小张'}] }}
				api: () => defHttp.get({ url: '/coupleUser/getCitysByTenantId' }),
				//数值转成String
				numberToString: false,
				//标题字段
				labelField: 'name',
				//值字段
				valueField: 'id',
				//请求参数
				params: {
				},
				//返回结果字段
				resultField: 'records'
			}

		},
	},
	{
		label: '备注',
		field: 'remark',
		component: 'InputTextArea',//TODO 注意string转换问题
		required: true
	},
	// TODO 主键隐藏字段，目前写死为ID
	{
		label: '',
		field: 'userid',
		component: 'Input',
		show: false
	},
	{
		label: '',
		field: 'id',
		component: 'Input',
		show: false
	},

];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData) : FormSchema[] {
	// 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
	return formSchema;
}